#ifndef INVENPARAMS_H
#define INVENPARAMS_H
#include "rfidlib.h"
#include "string.h"

class SELECTION
{
public:
    bool m_enable;
    BYTE m_target;
    BYTE m_action;
    BYTE m_memBank;
    INT m_pointer;
    int m_maskbits_len;
    BYTE* m_maskbits;
    SELECTION(const int max_size)
    {
        m_enable = false;
        m_target = 0x04;
        m_action = 0x00;
        m_memBank = 0x01; //EPC
        m_pointer = 0x20;
        m_maskbits_len=0x10;
        m_maskbits=new BYTE[max_size];
        memset(m_maskbits,'\0',max_size);
    }
    ~SELECTION()
    {
        if(m_maskbits != nullptr)
        {
            delete[] m_maskbits;
            m_maskbits = nullptr;
            m_maskbits_len=0;
        }
    }
};

class META_FLAGS
{
public:
    bool m_enable;
    bool m_EPC;
    bool m_antennaID;
    bool m_timestamp;
    bool m_frequency;
    bool m_RSSI;
    bool m_readCnt;
    bool m_tagData;

    META_FLAGS()
    {
        m_enable = true;
        m_EPC = true;
        m_antennaID = true;
        m_timestamp = false;
        m_frequency = false;
        m_RSSI = false;
        m_readCnt = false;
        m_tagData = false;
    }
};

class INVEN_READ
{
public:
    BYTE m_memBank;
    INT m_wordPtr;
    INT m_wordCnt;
    INVEN_READ()
    {
        m_memBank=0x03;
        m_wordPtr=0x00;
        m_wordCnt=0x01;
    }
};

class EMBEDDED_WRITE
{
public:
    bool m_enable;
    BYTE m_memBank;
    INT m_wordPtr;
    INT m_wordCnt;
    BYTE* m_datas;
    EMBEDDED_WRITE(const int max_size)
    {
        m_enable = false;
        m_memBank = 0x01;
        m_wordPtr = 0x02;
        m_wordCnt = 0x01;
        m_datas=new BYTE[max_size];
        memset(m_datas,'\0',max_size);
    }
    ~EMBEDDED_WRITE()
    {
        if(m_datas != nullptr)
        {
            delete[] m_datas;
            m_datas = nullptr;
            m_wordCnt=0;
        }
    }
};

class EMBEDDED_Lock
{
public:
    bool m_enable;
    bool m_userMemSelected;
    bool m_TIDMemSelected;
    bool m_EPCMemSelected;
    bool m_accessPwdSelected;
    bool m_killPwdSelected;
    INT m_userMem;
    INT m_TIDMem;
    INT m_EPCMem;
    INT m_accessPwd;
    INT m_killPwd;
    EMBEDDED_Lock()
    {
        m_enable = false;
        m_userMemSelected = false;
        m_TIDMemSelected = false;
        m_EPCMemSelected = false;
        m_accessPwdSelected = false;
        m_killPwdSelected = false;
        m_userMem = 0;
        m_TIDMem = 0;
        m_EPCMem = 0;
        m_accessPwd = 0;
        m_killPwd = 0;
    }
};

class InvenParams
{
public:
    SELECTION* m_sel;
    META_FLAGS* m_metaFlags;
    INVEN_READ* m_read;
    EMBEDDED_WRITE* m_write;
    EMBEDDED_Lock* m_lock;
    UINT32 m_accessPwd;
    UINT32 m_killPwd;
    UINT32 m_timeout;

    InvenParams(const int max_bytes_size);
    virtual ~InvenParams();
};

#endif // INVENPARAMS_H
